<template>
  <view class="record-page">
    <!-- 顶部导航栏 -->
    <view class="header">
      <view class="nav-bar">
        <view class="nav-left"></view>
       <!-- <text class="nav-title">救援记录</text> -->
        <view class="nav-right"></view>
      </view>
    </view>
    
    <!-- 救援记录列表 -->
    <view class="record-list">
      <view class="record-card" v-for="(record, index) in recordList" :key="index" @click="viewRecordDetail(record)">
        <view class="card-header">
          <view class="service-tag" :class="record.serviceType">{{ record.serviceName }}</view>
          <view class="record-date">{{ record.date }}</view>
        </view>
        <view class="card-content">
          <view class="info-row">
            <text class="info-label">订单编号:</text>
            <text class="info-value">{{ record.orderNumber }}</text>
          </view>
          <view class="info-row" v-if="record.serviceType === 'towing'">
            <text class="info-label">起点:</text>
            <text class="info-value">{{ record.startLocation }}</text>
          </view>
          <view class="info-row" v-if="record.serviceType === 'towing'">
            <text class="info-label">终点:</text>
            <text class="info-value">{{ record.endLocation }}</text>
          </view>
          <view class="info-row" v-if="record.serviceType !== 'towing'">
            <text class="info-label">位置:</text>
            <text class="info-value">{{ record.location }}</text>
          </view>
          <view class="info-row">
            <text class="info-label">车牌:</text>
            <text class="info-value">{{ record.plateNumber }}</text>
          </view>
        </view>
      </view>
    </view>

    <!-- 空状态 -->
    <view v-if="recordList.length === 0" class="empty-state">
      <view class="empty-icon">📋</view>
      <text class="empty-text">暂无救援记录</text>
      <text class="empty-desc">您还没有发起过救援服务</text>
    </view>

    <!-- 底部占位 -->
    <view class="bottom-tab-placeholder"></view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      recordList: [
        {
          serviceType: 'tire-change',
          serviceName: '换胎',
          date: '2023-02-15',
          orderNumber: '121212112487878',
          startLocation: '',
          endLocation: '',
          location: '洛阳市道北路32号XXX小区',
          plateNumber: '奔驰FWE4/豫A98FHJ',
          status: 'completed'
        },
        {
          serviceType: 'towing',
          serviceName: '拖车',
          date: '2023-02-15',
          orderNumber: '121212112487878',
          startLocation: '洛阳市道北路32号XXX小区',
          endLocation: '洛阳市道北路39号XXXXXX小区',
          location: '',
          plateNumber: '奔驰FWE4/豫A98FHJ',
          status: 'completed'
        },
        {
          serviceType: 'jump-start',
          serviceName: '搭电',
          date: '2023-02-15',
          orderNumber: '121212112487878',
          startLocation: '',
          endLocation: '',
          location: '洛阳市道北路32号XXX小区',
          plateNumber: '奔驰FWE4/豫A98FHJ',
          status: 'completed'
        }
      ]
    }
  },
  onLoad() {
    console.log('救援记录页面加载');
  },
  methods: {
    // 查看记录详情
    viewRecordDetail(record) {
      console.log('查看记录详情:', record);
      uni.showModal({
        title: '救援记录详情',
        content: `服务类型：${record.serviceName}\n订单编号：${record.orderNumber}\n状态：已完成`,
        showCancel: false,
        confirmText: '确定'
      });
    }
  }
}
</script>

<style scoped>
.record-page {
  background: #f5f5f5;
  min-height: 100vh;
  position: relative; /* 作为伪元素定位参考 */
}

/* 页面背景色区域 - 顶部蓝色区域 */
.record-page::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 200rpx; /* 蓝色区域高度 */
  background-color: #3184FD;
  z-index: 0; /* 在页面内容下方 */
}

/* 顶部导航栏 */
.header {
  background: transparent;
  padding-top: var(--status-bar-height, 0);
  position: relative;
  z-index: 10;
}

.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 88rpx;
  padding: 0 32rpx;
  position: relative;
  color: #fff;
}

.nav-left {
  display: flex;
  align-items: center;
  width: 80rpx;
}

.nav-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 36rpx;
  font-weight: 600;
  color: #fff;
}

.nav-right {
  width: 80rpx;
}

/* 记录列表 */
.record-list {
  padding: 20rpx;
  display: flex;
  flex-direction: column;
  gap: 16rpx;
  position: relative;
  z-index: 10;
  margin-top: 0;
}

.record-card {
  background: #fff;
  border-radius: 20rpx;
  padding: 28rpx;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
  border: 1rpx solid rgba(0, 0, 0, 0.05);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18rpx;
}

.service-tag {
  font-size: 26rpx;
  font-weight: 600;
  color: #0a78ff;
  padding: 8rpx 16rpx;
  border-radius: 16rpx;
  background: #e6f3ff;
  box-shadow: 0 1rpx 4rpx rgba(10, 120, 255, 0.1);
}

.service-tag.tire-change {
  color: #0a78ff;
  background: #e6f3ff;
}

.service-tag.towing {
  color: #0a78ff;
  background: #e6f3ff;
}

.service-tag.jump-start {
  color: #0a78ff;
  background: #e6f3ff;
}

.record-date {
  font-size: 24rpx;
  color: #999;
  font-weight: 400;
}

.card-content {
  display: flex;
  flex-direction: column;
  gap: 6rpx;
}

.info-row {
  display: flex;
  align-items: flex-start;
  gap: 12rpx;
  margin-bottom: 4rpx;
}

.info-label {
  font-size: 24rpx;
  color: #999;
  min-width: 120rpx;
  line-height: 1.5;
  font-weight: 400;
}

.info-value {
  font-size: 24rpx;
  color: #333;
  flex: 1;
  line-height: 1.5;
  font-weight: 400;
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 100rpx 40rpx;
  text-align: center;
  background: #fff;
  border-radius: 20rpx;
  margin: 20rpx;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
}

.empty-icon {
  font-size: 120rpx;
  margin-bottom: 30rpx;
  opacity: 0.5;
}

.empty-text {
  font-size: 32rpx;
  color: #666;
  margin-bottom: 16rpx;
  font-weight: 500;
}

.empty-desc {
  font-size: 28rpx;
  color: #999;
  line-height: 1.4;
}

.bottom-tab-placeholder {
  height: 140rpx;
}
</style>
